﻿<views:MvxPhonePage
    x:Class="Bulb.UI.WindowsPhone.Views.AddBulbView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:views="clr-namespace:Cirrious.MvvmCross.WindowsPhone.Views;assembly=Cirrious.MvvmCross.WindowsPhone"
    xmlns:binding="clr-namespace:Coding4Fun.Toolkit.Controls.Binding;assembly=Coding4Fun.Toolkit.Controls"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource ApplicationName}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{Binding TextSource, Converter={StaticResource Language}, ConverterParameter=AddBulb, FallbackValue=AddBulb, Mode=OneTime}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" />
        </StackPanel>

        <ScrollViewer x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <StackPanel>
                <StackPanel>
                    <TextBlock Text="{Binding TextSource, Converter={StaticResource Language}, ConverterParameter=Name, FallbackValue=Name, Mode=OneTime}" FontSize="{StaticResource PhoneFontSizeMedium}"></TextBlock>
                    <TextBox Text="{Binding Name, Mode=TwoWay, FallbackValue=Name}" binding:TextBinding.UpdateSourceOnChange="True"></TextBox>
                </StackPanel>
                
                <StackPanel Margin="0,12,0,0">
                    <TextBlock Text="{Binding TextSource, Converter={StaticResource Language}, ConverterParameter=Description, FallbackValue=Description, Mode=OneTime}" FontSize="{StaticResource PhoneFontSizeMedium}"></TextBlock>
                    <TextBox Text="{Binding Description, Mode=TwoWay, FallbackValue=Description}" binding:TextBinding.UpdateSourceOnChange="True"></TextBox>
                </StackPanel>
                
                <StackPanel Margin="24,12,24,0">
                    <Button Content="{Binding TextSource, Converter={StaticResource Language}, ConverterParameter=DeletePicture, FallbackValue=DeletePicture, Mode=OneTime}" Command="{Binding DeletePictureCommand}" Visibility="{Binding MakeItVisible, Converter={StaticResource Visibility}}"/>
                    <Button Content="{Binding TextSource, Converter={StaticResource Language}, ConverterParameter=SelectPicture, FallbackValue=SelectPicture, Mode=OneTime}" Command="{Binding ChoosePictureCommand}" Visibility="{Binding MakeItVisible, Converter={StaticResource InvertedVisibility}}" />
                    <Button Content="{Binding TextSource, Converter={StaticResource Language}, ConverterParameter=TakePicture, FallbackValue=TakePicture, Mode=OneTime}" Command="{Binding TakePictureCommand}" Visibility="{Binding MakeItVisible, Converter={StaticResource InvertedVisibility}}"/>
                </StackPanel>

                <Image Height="150" Width="150" Source="{Binding PictureBytes, Converter={StaticResource BytesToImage}}"></Image>
            </StackPanel>
        </ScrollViewer>
    </Grid>

    <views:MvxPhonePage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBar.Buttons>
                <shell:ApplicationBarIconButton IconUri="/Toolkit.Content/ApplicationBar.Add.png" Text="Add" Click="ApplicationBarIconButton_OnClick" />
            </shell:ApplicationBar.Buttons>
        </shell:ApplicationBar>
    </views:MvxPhonePage.ApplicationBar>
</views:MvxPhonePage>